package com.tengju.bff.interfaces.app.motivation.assembler;

import com.tengju.bff.interfaces.app.motivation.vo.BonusRankDetailVO;
import com.tengju.user.domain.model.user.StarLevelEnum;
import com.tengju.user.domain.model.user.UserInfo;

/**
 * @author chenhang
 * @Date 2021/7/23
 */
public class BonusRankAssembler {

    public static BonusRankDetailVO userToBonusRankDetail(UserInfo userInfo, String defaultImage) {
        if (userInfo == null) {
            return null;
        }
        BonusRankDetailVO bonusRankDetailVO = new BonusRankDetailVO();
        bonusRankDetailVO.setIdCode(userInfo.getIdCode().getValue());
        bonusRankDetailVO.setHeadImg(userInfo.getHeadImage() == null ? defaultImage : userInfo.getHeadImage());
        bonusRankDetailVO.setNickName(userInfo.getBackNickName());
        bonusRankDetailVO.setStarLevelDesc(StarLevelEnum.parseByCode(
                userInfo.getStarLevel()) == null ? "" : StarLevelEnum.parseByCode(userInfo.getStarLevel()).getDesc()
        );
        bonusRankDetailVO.setStarLevel(userInfo.getStarLevel());
        return bonusRankDetailVO;

    }
}
